package com.mrx.commons.gateway.controller;

import com.mrx.commons.gateway.service.GatewayDispatchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Mr.X
 * @since 2024/6/2 上午9:27
 */
@RestController
public class GatewayController {

    @Resource
    private GatewayDispatchService gatewayDispatchService;

    private static final Logger logger = LoggerFactory.getLogger(GatewayController.class);

    @PostConstruct
    public void init() {
        logger.info("启用 commons-gateway");
    }

    @RequestMapping("/**")
    public void dispatchRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        gatewayDispatchService.dispatchRequest(request, response);
    }

}
